package com.dalin.platform.loa.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import com.dalin.common.base.BaseObject;
import com.dalin.platform.pub.PlatContext;
/*****************************************************************************
 * @content: 类信息                                                                                                                                *
 * @author : 那建林                                                                                                                                 *
 * @crtDate: 2010-09-28 16:04:06                                            *
 * @modDate: 2010-09-28 16:04:06                                            *
 * @version: 1.00                                                           *
 ****************************************************************************/
@Entity
@Table(name="LOA_PUBLIC_HEADER")
public class LoaPublicHeaderEntity extends BaseObject {
    private Long headerId; // HEADER_ID,16,0,序号
    private String labelName; // LABEL_NAME,256,0,标签名称
    private String propertyName; // PROPERTY_NAME,256,0,属性名称
    private Long menuId;



    @Id
    @Column(name="HEADER_ID")
    @GeneratedValue(strategy = GenerationType.TABLE,generator="generator_normal")
    @TableGenerator(
        name = "generator_normal",
        table = "GLB_GENERATOR_KEY",
        pkColumnName = "GEN_KEY",
        valueColumnName = "GEN_VALUE",
        pkColumnValue = "GLB_GRID_HEADER",
        allocationSize=1
    )
    public Long getHeaderId() {
        return headerId;
    }

    public void setHeaderId(Long headerId) {
        this.headerId = headerId;
    }

    @Column(name="LABEL_NAME")
    public String getLabelName() {
        return labelName;
    }

    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }

    @Column(name="PROPERTY_NAME")
    public String getPropertyName() {
        return propertyName;
    }

    public void setPropertyName(String propertyName) {
        this.propertyName = propertyName;
    }

    @Column(name="MENU_ID")
    public Long getMenuId() {
		return menuId;
	}

	public void setMenuId(Long menuId) {
		this.menuId = menuId;
	}

	
	@Transient
    public LoaMenuEntity getLoaMenuEntity() throws Exception {
		return (LoaMenuEntity) PlatContext.getDao()
			.findObjById(LoaMenuEntity.class, this.getMenuId());
	}
	
	@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof LoaPublicHeaderEntity)) return false;
        final LoaPublicHeaderEntity other = (LoaPublicHeaderEntity) o;
        if (headerId == null) {
            if (other.headerId != null) return false;
        } else if (!headerId.equals(other.headerId)) {
            return false;
        }
        if (labelName == null) {
            if (other.labelName != null) return false;
        } else if (!labelName.equals(other.labelName)) {
            return false;
        }
        if (propertyName == null) {
            if (other.propertyName != null) return false;
        } else if (!propertyName.equals(other.propertyName)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int njlrst = 17;
        njlrst = 31 * njlrst + (headerId == null ? 0 : headerId.hashCode());
        njlrst = 31 * njlrst + (labelName == null ? 0 : labelName.hashCode());
        njlrst = 31 * njlrst + (propertyName == null ? 0 : propertyName.hashCode());
        return njlrst;
    }
}
